package net.peelmeagrape.hibernate;

import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;

import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Specifies a cache concurrency strategy.
 */
@Retention(RUNTIME)
@XmlElement(name="cache")
public @interface Cache
{
    @XmlAttribute String region() default "";
    @XmlAttribute Usage usage();

    /**
     * Specifies a cache concurrency strategy.
     */
    public enum Usage
    {
        READ_ONLY("read-only"),
        READ_WRITE("read-write"),
        NONSTRICT_READWRITE("nonstrict-read-write"),
        TRANSACTIONAL("transactional");
        private String value;

        Usage(String value)
        {
            this.value = value;
        }

        public String toString()
        {
            return value;
        }
    }
}
